const set = new Set();

// challenge Set

class MySet<T> {
  constructor(private set: T[] = []) {}

  has(value: T): boolean {
    return this.set.includes(value);
  }

  add(value: T): void {
    if (!this.has(value)) {
      this.set.push(value);
    }
  }

  get size(): number {
    return this.set.length;
  }

  clear(): void {
    this.set = [];
  }

  delete(value: T): void {
    this.set = this.set.filter((i) => i !== value);
  }
}

const myset1 = new MySet([1, 2]);
console.log(myset1.size);
myset1.add(3);
console.log(myset1);
myset1.delete(2);
console.log(myset1);
